namespace InventoryManagement
{
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.Data;
	using System.Data.SqlClient;
	using System.Text;
	
	
	public class Checklist_Physical : BaseTable
	{
		
		#region Static SQL String Members
		/// <remarks>This field represents the full SELECT string for the table Checklist Physical, with the WHERE clause.</remarks>
		internal static string _SQL_Select = "SELECT [ID], [ID_PhysicalServer], [Physical], [PowerSupply], [HDD], [Memory], [FAN], [Ethernet], [Notes], [Date], [URLAttachment], [CheckListBy] FROM [dbo].[Checklist Physical] WHERE [ID]=@ID ";
		
		/// <remarks>This field represents the full SELECT string for the table Checklist Physical, with the WHERE clause.</remarks>
		internal static string _SQL_SelectByParam = "SELECT [ID], [ID_PhysicalServer], [Physical], [PowerSupply], [HDD], [Memory], [FAN], [Ethernet], [Notes], [Date], [URLAttachment], [CheckListBy] FROM [dbo].[Checklist Physical] WHERE isnull(convert(varchar(36),[ID]),\'true\')=isnull(convert(varchar(36),@ID),isnull(convert(varchar(36),[ID]),\'true\')) AND isnull(convert(varchar(36),[ID_PhysicalServer]),\'true\')=isnull(convert(varchar(36),@ID_PhysicalServer),isnull(convert(varchar(36),[ID_PhysicalServer]),\'true\')) AND isnull(convert(varchar,[Physical]),\'true\')=isnull(convert(varchar,@Physical),isnull(convert(varchar,[Physical]),\'true\')) AND isnull(convert(varchar,[PowerSupply]),\'true\')=isnull(convert(varchar,@PowerSupply),isnull(convert(varchar,[PowerSupply]),\'true\')) AND isnull(convert(varchar,[HDD]),\'true\')=isnull(convert(varchar,@HDD),isnull(convert(varchar,[HDD]),\'true\')) AND isnull(convert(varchar,[Memory]),\'true\')=isnull(convert(varchar,@Memory),isnull(convert(varchar,[Memory]),\'true\')) AND isnull(convert(varchar,[FAN]),\'true\')=isnull(convert(varchar,@FAN),isnull(convert(varchar,[FAN]),\'true\')) AND isnull(convert(varchar,[Ethernet]),\'true\')=isnull(convert(varchar,@Ethernet),isnull(convert(varchar,[Ethernet]),\'true\')) AND isnull(convert(varchar,[Notes]),\'true\')=isnull(convert(varchar,@Notes),isnull(convert(varchar,[Notes]),\'true\')) AND isnull(convert(varchar,[Date]),\'true\')=isnull(convert(varchar,@Date),isnull(convert(varchar,[Date]),\'true\')) AND isnull(convert(varchar,[URLAttachment]),\'true\')=isnull(convert(varchar,@URLAttachment),isnull(convert(varchar,[URLAttachment]),\'true\')) AND isnull(convert(varchar,[CheckListBy]),\'true\')=isnull(convert(varchar,@CheckListBy),isnull(convert(varchar,[CheckListBy]),\'true\')) ";
		
		/// <remarks>This field represents the full INSERT INTO string for the table Checklist Physical.</remarks>
		internal static string _SQL_Insert = @"INSERT INTO [dbo].[Checklist Physical] ([ID], [ID_PhysicalServer], [Physical], [PowerSupply], [HDD], [Memory], [FAN], [Ethernet], [Notes], [Date], [URLAttachment], [CheckListBy]) VALUES(@ID, @ID_PhysicalServer, @Physical, @PowerSupply, @HDD, @Memory, @FAN, @Ethernet, @Notes, @Date, @URLAttachment, @CheckListBy) ";
		
		/// <remarks>This field represents the full UPDATE string for the table Checklist Physical, with the WHERE clause.</remarks>
		internal static string _SQL_Update = @"UPDATE [dbo].[Checklist Physical] SET [ID] = @ID, [ID_PhysicalServer] = @ID_PhysicalServer, [Physical] = @Physical, [PowerSupply] = @PowerSupply, [HDD] = @HDD, [Memory] = @Memory, [FAN] = @FAN, [Ethernet] = @Ethernet, [Notes] = @Notes, [Date] = @Date, [URLAttachment] = @URLAttachment, [CheckListBy] = @CheckListBy WHERE [ID]=@ID ";
		
		/// <remarks>This field represents the DELETE string for the table Checklist Physical, with the WHERE clause.</remarks>
		internal static string _SQL_Delete = "DELETE FROM [dbo].[Checklist Physical] WHERE [ID]=@ID ";
		#endregion
		
		#region Tables Members
		/// <remarks>SQL Type:uniqueidentifier - </remarks>
		private System.Nullable<System.Guid> _ID;
		
		[DisplayName("ID")]
		[Category("Primary Key")]
		public System.Nullable<System.Guid> ID
		{
			get
			{
				try
				{
					return _ID;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ID", err);
				}
			}
			set
			{
				try
				{
					_ID = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ID", err);
				}
			}
		}
		
		/// <remarks>SQL Type:uniqueidentifier - </remarks>
		private System.Nullable<System.Guid> _ID_PhysicalServer;
		
		[DisplayName("ID_Physical Server")]
		[Category("Foreign Key")]
		public System.Nullable<System.Guid> ID_PhysicalServer
		{
			get
			{
				try
				{
					return _ID_PhysicalServer;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ID_PhysicalServer", err);
				}
			}
			set
			{
				try
				{
					_ID_PhysicalServer = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ID_PhysicalServer", err);
				}
			}
		}
		
		/// <remarks>SQL Type:bit - </remarks>
		private System.Nullable<bool> _Physical;
		
		[DisplayName("Physical")]
		[Category("Column")]
		public System.Nullable<bool> Physical
		{
			get
			{
				try
				{
					return _Physical;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Physical", err);
				}
			}
			set
			{
				try
				{
					_Physical = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Physical", err);
				}
			}
		}
		
		/// <remarks>SQL Type:bit - </remarks>
		private System.Nullable<bool> _PowerSupply;
		
		[DisplayName("Power Supply")]
		[Category("Column")]
		public System.Nullable<bool> PowerSupply
		{
			get
			{
				try
				{
					return _PowerSupply;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting PowerSupply", err);
				}
			}
			set
			{
				try
				{
					_PowerSupply = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting PowerSupply", err);
				}
			}
		}
		
		/// <remarks>SQL Type:bit - </remarks>
		private System.Nullable<bool> _HDD;
		
		[DisplayName("HDD")]
		[Category("Column")]
		public System.Nullable<bool> HDD
		{
			get
			{
				try
				{
					return _HDD;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting HDD", err);
				}
			}
			set
			{
				try
				{
					_HDD = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting HDD", err);
				}
			}
		}
		
		/// <remarks>SQL Type:bit - </remarks>
		private System.Nullable<bool> _Memory;
		
		[DisplayName("Memory")]
		[Category("Column")]
		public System.Nullable<bool> Memory
		{
			get
			{
				try
				{
					return _Memory;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Memory", err);
				}
			}
			set
			{
				try
				{
					_Memory = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Memory", err);
				}
			}
		}
		
		/// <remarks>SQL Type:bit - </remarks>
		private System.Nullable<bool> _FAN;
		
		[DisplayName("FAN")]
		[Category("Column")]
		public System.Nullable<bool> FAN
		{
			get
			{
				try
				{
					return _FAN;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting FAN", err);
				}
			}
			set
			{
				try
				{
					_FAN = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting FAN", err);
				}
			}
		}
		
		/// <remarks>SQL Type:bit - </remarks>
		private System.Nullable<bool> _Ethernet;
		
		[DisplayName("Ethernet")]
		[Category("Column")]
		public System.Nullable<bool> Ethernet
		{
			get
			{
				try
				{
					return _Ethernet;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Ethernet", err);
				}
			}
			set
			{
				try
				{
					_Ethernet = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Ethernet", err);
				}
			}
		}
		
		/// <remarks>SQL Type:varchar - </remarks>
		private string _Notes;
		
		[DisplayName("Notes")]
		[Category("Column")]
		public string Notes
		{
			get
			{
				try
				{
					return _Notes;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Notes", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 1000))
					{
						_Notes = value;
					}
					else
					{
						throw new OverflowException("Error setting Notes, Length of value is to long. Maximum Length: 1000");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Notes", err);
				}
			}
		}
		
		/// <remarks>SQL Type:datetime - </remarks>
		private System.Nullable<System.DateTime> _Date;
		
		[DisplayName("Date")]
		[Category("Column")]
		public System.Nullable<System.DateTime> Date
		{
			get
			{
				try
				{
					return _Date;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Date", err);
				}
			}
			set
			{
				try
				{
					_Date = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Date", err);
				}
			}
		}
		
		/// <remarks>SQL Type:varchar - </remarks>
		private string _URLAttachment;
		
		[DisplayName("URLAttachment")]
		[Category("Column")]
		public string URLAttachment
		{
			get
			{
				try
				{
					return _URLAttachment;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting URLAttachment", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 400))
					{
						_URLAttachment = value;
					}
					else
					{
						throw new OverflowException("Error setting URLAttachment, Length of value is to long. Maximum Length: 400");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting URLAttachment", err);
				}
			}
		}
		
		/// <remarks>SQL Type:varchar - </remarks>
		private string _CheckListBy;
		
		[DisplayName("Check List By")]
		[Category("Column")]
		public string CheckListBy
		{
			get
			{
				try
				{
					return _CheckListBy;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting CheckListBy", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 200))
					{
						_CheckListBy = value;
					}
					else
					{
						throw new OverflowException("Error setting CheckListBy, Length of value is to long. Maximum Length: 200");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting CheckListBy", err);
				}
			}
		}
		#endregion
		
		#region Related Objects
		/// <remarks>Represents the foreign key object</remarks>
		private Inventory_Physical _ID_PhysicalServer_Inventory_Physical;
		
		[Description("Represents the foreign key object of the type Inventory_Physical")]
		public Inventory_Physical ID_PhysicalServer_Inventory_Physical
		{
			get
			{
				try
				{
					return _ID_PhysicalServer_Inventory_Physical;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ID_PhysicalServer_Inventory_Physical", err);
				}
			}
			set
			{
				try
				{
					_ID_PhysicalServer_Inventory_Physical = value;
					_ID_PhysicalServer = _ID_PhysicalServer_Inventory_Physical.ID;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ID_PhysicalServer_Inventory_Physical", err);
				}
			}
		}
		#endregion
		
		#region Public Methods
		public void Select()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = Checklist_Physical._SQL_Select;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				SqlDataReader rs = Com.ExecuteReader();
				while(rs.Read())
				{
					AddFromRecordSet(rs);
				}
				rs.Close();
				Conn.Close();
				rs.Dispose();
				Com.Dispose();
				Conn.Dispose();
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public System.Data.DataTable SelectByParam()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = Checklist_Physical._SQL_SelectByParam;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				SqlDataAdapter objDataAdapter = new SqlDataAdapter(Com);
				DataTable objDataTable = new DataTable();
				objDataAdapter.Fill(objDataTable);
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return objDataTable;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Insert()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = Checklist_Physical._SQL_Insert;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Update()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = Checklist_Physical._SQL_Update;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Delete()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = Checklist_Physical._SQL_Delete;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public string[] GetSqlCommandStrings()
		{
			try
			{
				string[] CommStr = new string[4];
				CommStr[0] = "SELECT [ID], [ID_PhysicalServer], [Physical], [PowerSupply], [HDD], [Memory], [FAN], [Ethernet], [Notes], [Date], [URLAttachment], [CheckListBy] FROM [dbo].[Checklist Physical] WHERE [ID] = " + _ID + "";
				CommStr[1] = "INSERT INTO [dbo].[Checklist Physical] ([ID], [ID_PhysicalServer], [Physical], [PowerSupply], [HDD], [Memory], [FAN], [Ethernet], [Notes], [Date], [URLAttachment], [CheckListBy]) VALUES(" + _ID + ", " + _ID_PhysicalServer + ", " + _Physical + ", " + _PowerSupply + ", " + _HDD + ", " + _Memory + ", " + _FAN + ", " + _Ethernet + ", '" + _Notes.Replace("'","''") + "', '" + _Date + "', '" + _URLAttachment.Replace("'","''") + "', '" + _CheckListBy.Replace("'","''") + "')";
				CommStr[2] = "UPDATE [dbo].[Checklist Physical] SET [ID_PhysicalServer] = " + _ID_PhysicalServer + " ,[Physical] = " + _Physical + " ,[PowerSupply] = " + _PowerSupply + " ,[HDD] = " + _HDD + " ,[Memory] = " + _Memory + " ,[FAN] = " + _FAN + " ,[Ethernet] = " + _Ethernet + " ,[Notes] = '" + _Notes.Replace("'","''") + "' ,[Date] = '" + _Date + "' ,[URLAttachment] = '" + _URLAttachment.Replace("'","''") + "' ,[CheckListBy] = '" + _CheckListBy.Replace("'","''") + "' WHERE [ID] = " + _ID + "";
				CommStr[3] = "DELETE FROM [dbo].[Checklist Physical] WHERE [ID] = " + _ID + "";
				return CommStr;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		#endregion
		
		#region Private Methods
		private void AddFromRecordSet(SqlDataReader rs)
		{
			try
			{
				// if value from the recordset, to the ID field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("ID")) == false))
				{
					ID = rs.GetGuid(rs.GetOrdinal("ID"));
				}
				// if value from the recordset, to the ID_PhysicalServer field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("ID_PhysicalServer")) == false))
				{
					ID_PhysicalServer = rs.GetGuid(rs.GetOrdinal("ID_PhysicalServer"));
				}
				// if value from the recordset, to the Physical field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Physical")) == false))
				{
					Physical = rs.GetBoolean(rs.GetOrdinal("Physical"));
				}
				// if value from the recordset, to the PowerSupply field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("PowerSupply")) == false))
				{
					PowerSupply = rs.GetBoolean(rs.GetOrdinal("PowerSupply"));
				}
				// if value from the recordset, to the HDD field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("HDD")) == false))
				{
					HDD = rs.GetBoolean(rs.GetOrdinal("HDD"));
				}
				// if value from the recordset, to the Memory field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Memory")) == false))
				{
					Memory = rs.GetBoolean(rs.GetOrdinal("Memory"));
				}
				// if value from the recordset, to the FAN field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("FAN")) == false))
				{
					FAN = rs.GetBoolean(rs.GetOrdinal("FAN"));
				}
				// if value from the recordset, to the Ethernet field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Ethernet")) == false))
				{
					Ethernet = rs.GetBoolean(rs.GetOrdinal("Ethernet"));
				}
				// if value from the recordset, to the Notes field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Notes")) == false))
				{
					Notes = rs.GetString(rs.GetOrdinal("Notes"));
				}
				// if value from the recordset, to the Date field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Date")) == false))
				{
					Date = rs.GetDateTime(rs.GetOrdinal("Date"));
				}
				// if value from the recordset, to the URLAttachment field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("URLAttachment")) == false))
				{
					URLAttachment = rs.GetString(rs.GetOrdinal("URLAttachment"));
				}
				// if value from the recordset, to the CheckListBy field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("CheckListBy")) == false))
				{
					CheckListBy = rs.GetString(rs.GetOrdinal("CheckListBy"));
				}
			}
			catch (SqlException sqlExc)
			{
				throw sqlExc;
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		
		private SqlParameter[] GetSqlParameters()
		{
			List<SqlParameter> SqlParmColl = new List<SqlParameter>();
			try
			{
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@ID", ID, SqlDbType.UniqueIdentifier));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@ID_PhysicalServer", ID_PhysicalServer, SqlDbType.UniqueIdentifier));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@Physical", Physical, SqlDbType.Bit));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@PowerSupply", PowerSupply, SqlDbType.Bit));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@HDD", HDD, SqlDbType.Bit));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@Memory", Memory, SqlDbType.Bit));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@FAN", FAN, SqlDbType.Bit));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@Ethernet", Ethernet, SqlDbType.Bit));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@Notes", Notes, SqlDbType.VarChar));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@Date", Date, SqlDbType.DateTime));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@URLAttachment", URLAttachment, SqlDbType.VarChar));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@CheckListBy", CheckListBy, SqlDbType.VarChar));
				return SqlParmColl.ToArray();
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		#endregion
	}
	
	public class Checklist_PhysicalCollection : System.Collections.CollectionBase
	{
		
		[Description("Adds a new Checklist_Physical to the collection.")]
		public int Add(Checklist_Physical item)
		{
			int newindex = List.Add(item);
			return newindex;
		}
		
		[Description("Removes a Checklist_Physical from the collection.")]
		public void Remove(Checklist_Physical item)
		{
			List.Remove(item);
		}
		
		[Description("Inserts an Checklist_Physical into the collection at the specified index.")]
		public void Insert(int index, Checklist_Physical item)
		{
			List.Insert(index, item);
		}
		
		[Description("Returns the index value of the Checklist_Physical class in the collection.")]
		public int IndexOf(Checklist_Physical item)
		{
			return List.IndexOf(item);
		}
		
		[Description("Returns true if the Checklist_Physical class is present in the collection.")]
		public bool Contains(Checklist_Physical item)
		{
			return List.Contains(item);
		}
	}
	
	public enum Checklist_Physical_Fields
	{
		
		ID,
		
		ID_PhysicalServer,
		
		Physical,
		
		PowerSupply,
		
		HDD,
		
		Memory,
		
		FAN,
		
		Ethernet,
		
		Notes,
		
		Date,
		
		URLAttachment,
		
		CheckListBy,
	}
}
